import React, {Component, createRef} from 'react';
import echarts from 'echarts';

class EChartDemo extends Component {
  constructor(props) {
    super(props);
    this.eCharts = createRef()
  }


  componentDidMount() {

    console.log(this.eCharts.current);
    //需要传递的是一个dom节点
    let eCharts = echarts.init(this.eCharts.current);
    eCharts.setOption({
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
      },
      yAxis: {
        type: 'value'
      },
      series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
        areaStyle: {}
      }]
    }

  )

  }

  render() {
    // 纯计算

    return (
      <div ref={this.eCharts} style={{width: 600, height: 400}}>

      </div>
    );
  }
}

export default EChartDemo;
